/*
 * @message: 描述
 * @Author: Roy
 * @Email: @163.com
 * @Github: @163.com
 * @Date: 2021-11-20 14:25:57
 * @LastEditors: Roy
 * @LastEditTime: 2021-11-26 14:59:02
 * @Deprecated: 否
 * @FilePath: /train-ticket/src/pages/order/store/reducer.js
 */
import * as actionTypes from './actionTypes'
const defaultState = {
    trainNumber: null,// 车次编号
    departStation: null,// 出发车站
    arriveStation: null,//到达车站
    seatType: null,//坐席类型
    departDate: Date.now(),//出发日期
    arriveDate: Date.now(),//到站日期
    departTimeStr: null,//出发时间字符串
    arriveTimeStr: null,//到站时间字符串
    durationStr: null,//行程时间
    price: null,//票价
    passengers: [],//所有乘客信息
    menu: null,
    isMenuVisible: false,//菜单是否可见
    searchParsed: false,//是否解析完成
};

// eslint-disable-next-line import/no-anonymous-default-export
export default (state = defaultState, action) => {
    let newState = JSON.parse(JSON.stringify(state));
    switch (action.type) {
        case actionTypes.ACTION_SET_TRAIN_NUMBER:
            newState.trainNumber = action.payload;
            return newState;
        case actionTypes.ACTION_SET_DEPART_STATION:
            newState.departStation = action.payload;
            return newState;
        case actionTypes.ACTION_SET_ARRIVE_STATION:
            newState.arriveStation = action.payload;
            return newState;
        case actionTypes.ACTION_SET_SEAT_TYPE:
            newState.seatType = action.payload;
            return newState;
        case actionTypes.ACTION_SET_DEPART_DATE:
            newState.departDate = action.payload;
            return newState;
        case actionTypes.ACTION_SET_ARRIVE_DATE:
            newState.arriveDate = action.payload;
            return newState;
        case actionTypes.ACTION_SET_DEPART_TIME_STR:
            newState.departTimeStr = action.payload;
            return newState;
        case actionTypes.ACTION_SET_ARRIVE_TIME_STR:
            newState.arriveTimeStr = action.payload;
            return newState;
        case actionTypes.ACTION_SET_DURATION_STR:
            newState.durationStr = action.payload;
            return newState;
        case actionTypes.ACTION_SET_PRICE:
            newState.price = action.payload;
            return newState;
        case actionTypes.ACTION_SET_PASSENGERS:
            newState.passengers = action.payload;
            return newState;
        case actionTypes.ACTION_SET_MENU:
            newState.menu = action.payload;
            return newState;
        case actionTypes.ACTION_SET_IS_MENU_VISIBLE:
            newState.isMenuVisible = action.payload;
            return newState;
        case actionTypes.ACTION_SET_SEARCH_PARSED:
            newState.searchParsed = action.payload;
            return newState;
        default:
            break;
    }
    return state;

};
